/*
 * @Author: DaTree
 * @Date: 2021-09-03 22:25:12
 * @LastEditTime: 2021-09-05 07:03:28
 * @LastEditors: DaTree
 * @Description: DaTreeEdit
 * @FilePath: \webrtc-player\demo_services\index.js
 * 天将降大任于是人也，必先苦其心志，劳其筋骨，饿其体肤，空乏其身，行拂乱其所为。 ——《孟子•告子下》
 * Copyright 2021 DaTree
 */

const server = require('./server')
var requestHandlers = require('./serverXHRSignalingChannel')
const log = require("./log").log;
const port = process.argv[2] || 5001;
const r404 = (info) => {
  const res = info.res;
  log('Request handler 404 was called.')
  res.writeHead(404, { "Context-Type": "text/plain" });
  res.write("404 Page Not Found");
  res.end();
}

//这里是配置路由
const handle = {};
handle["/"] = r404;
handle["/connect"] = requestHandlers.connect;
handle["/send"] = requestHandlers.send;
handle["/get"] = requestHandlers.get;
server.serveFilePath("static");
server.start(handle, port);